﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DATA.BusinessObjects;

namespace Presentation
{
    public partial class frmCapNhatDonGiaLoaiPhong : Form
    {
        public frmCapNhatDonGiaLoaiPhong()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmThayDoiQuiDinh1_Load(object sender, EventArgs e)
        {
            IList<Phong> list_p = PhongBUS.LayDanhSachPhong();

            cbxTenPhong.DataSource = list_p;
            cbxTenPhong.DisplayMember = "TenPhong";
            cbxTenPhong.ValueMember = "Id";
        }

        private void cbxTenPhong_SelectedIndexChanged(object sender, EventArgs e)
        {
            Phong p = (Phong) cbxTenPhong.SelectedItem;
            Loaiphong lp = p.Loaiphong;

            txtDonGia.Text = lp.DonGia.Value.ToString();
        }

        private void btnThayDoi_Click(object sender, EventArgs e)
        {
            Phong p = (Phong) cbxTenPhong.SelectedItem;
            p.Loaiphong.DonGia = float.Parse(txtDonGia.Text);

            if (PhongBUS.CapNhatPhong(p))
                MessageBox.Show("Đã thay đổi thành công!!!");
            else
                MessageBox.Show("Không thay đổi thành công!!!");
        }
    }
}
